package o;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.huawei.appgallery.forum.user.api.OpenNickNameCheckerAction;
import com.huawei.appgallery.forum.user.userinfo.activity.PersonalDataActivity;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.widget.dialog.dialogactivity.DialogActivity;
import com.huawei.gamebox.plugin.gameservice.view.TransferActivity;
import o.ckh.a;

public class cbo extends cfh {
    private cbp ˊ;
    private Handler ˋ = new Handler(Looper.getMainLooper());
    private boolean ˎ;

    public cbo(Context context, cbp o_cbp, boolean z) {
        this.context = context;
        this.ˊ = o_cbp;
        this.ˎ = z;
    }

    public void doCheck() {
        bqx.ˏ("NicknameChecker", "start check if the nickname is empty");
        if (this.ˊ != null && this.ˊ.ॱ()) {
            checkSuccess();
        } else if (TextUtils.isEmpty(UserSession.getInstance().getNickname())) {
            ˎ();
        } else {
            checkSuccess();
        }
    }

    public String getName() {
        return "NicknameChecker";
    }

    private void ˋ() {
        OnDismissListener anonymousClass4 = new OnDismissListener(this) {
            final /* synthetic */ cbo ˏ;

            {
                this.ˏ = r1;
            }

            public void onDismiss(DialogInterface dialogInterface) {
                this.ˏ.checkFailed();
            }
        };
        if (this.ˎ) {
            OpenNickNameCheckerAction.setOnDismissListener(anonymousClass4);
            ((faj) cdb.ॱ(faj.class)).ˊ(this.context, TransferActivity.class, new Intent(OpenNickNameCheckerAction.ACTION));
            return;
        }
        cbk o_cbk = new cbk(this.context);
        o_cbk.ˎ(new a(this) {
            final /* synthetic */ cbo ˎ;

            {
                this.ˎ = r1;
            }

            public void ˏ(AlertDialog alertDialog, DialogActivity.a aVar, int i) {
                if (-1 == i) {
                    Intent intent = new Intent();
                    intent.setClass(this.ˎ.context, PersonalDataActivity.class);
                    if (!(this.ˎ.context instanceof Activity)) {
                        intent.setFlags(268435456);
                    }
                    this.ˎ.context.startActivity(intent);
                }
            }
        });
        o_cbk.ˏ(anonymousClass4);
        o_cbk.ˊ();
    }

    private void ˎ() {
        eqq.ˋ().ˎ("NicknameChecker", new eqn(this) {
            final /* synthetic */ cbo ˎ;

            {
                this.ˎ = r1;
            }

            public void onResult(final int i) {
                this.ˎ.ˋ.post(new Runnable(this) {
                    final /* synthetic */ AnonymousClass5 ˎ;

                    public void run() {
                        if (i != 202 || TextUtils.isEmpty(UserSession.getInstance().getNickname())) {
                            this.ˎ.ˎ.ˋ();
                        } else {
                            this.ˎ.ˎ.checkSuccess();
                        }
                    }
                });
                eqq.ˋ().ˊ("NicknameChecker");
            }
        });
        eox.ˎ(this.context, false);
    }
}
